;;;Search and replace text in a string.  Returns the new string if a match is found, else it returns original string.
;;;Search is case sensitive.
;;;Autolisp wildcard characters: *?,@`#.~ must each be preceded by the escape character ` for them to match as literal characters.
;;;i.e., the escape character ` causes the next character to be read literally.
;;;
;;;	Author:	Henry C. Francis
;;;		425 N. Ashe St.
;;;		Southern Pines, NC 28387
;;;		http://paracadd.com
;;;		All rights reserved.
;;;
;;;		COPYRIGHT: 
;;;		   EDITED: 
;;;
(DEFUN srstring (tstr chstr nwstr /)
  (IF (WCMATCH tstr (STRCAT "*" chstr "*"))
    (PROGN
      (SETQ match_cnt1
	     0
	    tmp_tstr tstr
      ) ;_ end of SETQ
      (WHILE (AND (/= tmp_tstr "")
		  (NOT (WCMATCH tmp_tstr (STRCAT chstr "*")))
	     ) ;_ end of AND
	(SETQ match_cnt1 (1+ match_cnt1)
	      tmp_tstr	 (SUBSTR tmp_tstr 2)
	) ;_ end of SETQ
      ) ;_ end of WHILE
      (WHILE (AND (/= tmp_tstr "") (NOT (WCMATCH tmp_tstr chstr)))
	(SETQ tmp_tstr (SUBSTR tmp_tstr 1 (1- (STRLEN tmp_tstr))))
      ) ;_ end of WHILE
      (SETQ match_cnt2 (+ match_cnt1 (STRLEN tmp_tstr)))
      (IF (EQ match_cnt1 0)
	(IF (EQ match_cnt2 (STRLEN tstr))
	  (SETQ istr nwstr)
	  (SETQ istr (STRCAT nwstr (SUBSTR tstr (1+ match_cnt2))))
	) ;_ end of IF
	(SETQ str1 (SUBSTR tstr 1 match_cnt1)
	      str2 (SUBSTR tstr (1+ match_cnt2))
	      istr (STRCAT str1 nwstr str2)
	) ;_ end of SETQ
      ) ;_ end of IF
    )
    (SETQ istr tstr)
  )
)